#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void solve()
{
	int n; cin >> n;
	vector<int> arr(n); for (auto& e : arr) cin >> e;
	sort(arr.begin(), arr.end());
	int ans = 0;
	for (int cur = 0; cur < n; ++cur)
	{
		if (arr[cur] == 0) continue;
		for (int i = cur, tmp = arr[cur]; i < n; ++i)
			arr[i] -= tmp;
		++ans;
	}
	if (ans) cout << ans * 2 - 1 << endl;
	else cout << 0 << endl;
}

int main()
{
	int t; cin >> t;
	while (t--) solve();
	return 0;
}


//4 3 1 1 3 1 100 9 9 9 3 2 4 4 8 5 3 1 0
